package com.jl.smartcard.ui.editors.cardfile;

import com.jl.util.HexUtil;

public class CardFileObject {

	private int index;
	private String value;
	private String backupValue;

	public CardFileObject(int index, byte[] value) {
		this.index = index;
		this.value = formatValue(value);
	}

	private String formatValue(byte[] value2) {
		StringBuilder sb = new StringBuilder();
		int left = value2.length;
		int step = 16;
		int off = 0;
		while(left > 0){
			int len = left > step ? step : left;
			sb.append(HexUtil.toHexString(value2, off, len));
			left -= len;
			off += len;
			sb.append("\n");
		}
		return sb.toString().trim();
	}

	public int getIndex() {
		return index;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value2) {
		backupValue = this.value;
		this.value = value2;
	}

	public void restore() {
		this.value = backupValue;
	}

}
